home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / ptv1n1.arc / MAKEFORM.PAS < prev    next >
Pascal/Delphi Source File  |  1990-06-08  |  2KB  |  60 lines

  1. (*
  2. **    File:    makeform.pas
  3. **    Purpose: Create a new card file
  4. **    Author:  (c) 1989 by Tom Swan. All rights reserved.
  5. *)
  6.  
  7. program MakeForm;
  8.  
  9. uses Crt, Forms, Sliders, uNewType, uFormGen;
  10.  
  11. type  FnameString = string[65];     { File name string type }
  12.  
  13. const FORMFILE = 'TEST.DTA';        { Name for new file }
  14.  
  15.    
  16. {---- Design a new data-entry form. }
  17.  
  18. {$F+}    { Turn on far-code generation. }
  19. procedure newForm;
  20. begin
  21.    theForm.init( 9, 4, 71, 22 );
  22.    theForm.add( new( FStrPtr,   
  23.       init(  3,  3, ' Name   :', 30 ) ) );
  24.    theForm.add( new( FIntPtr,   
  25.       init(  3,  4, ' Age    :', 0, 999 ) ) );
  26.    theForm.add( new( FYesNoPtr, 
  27.       init(  3,  5, ' Single :' ) ) );
  28. end; { newForm }
  29. {$F-}    { Turn off "far" code generation. }
  30.  
  31.  
  32. {---- Return True if file exists in current directory }
  33.  
  34. function fileExists( fname : FnameString ) : Boolean;
  35. var
  36.    f : File;
  37. begin
  38.    assign( f, fname );
  39.    {$i-} reset( f ); {$i+}    { Try to open the file }
  40.    if ioresult = 0 then
  41.    begin
  42.       fileExists := True;     { Return true if file open }
  43.       close( f )              { Then, close the file }
  44.    end else
  45.       FileExists := False     { Return false if not open }
  46. end; { FileExists }
  47.  
  48.  
  49. {---- Main program }
  50.  
  51. begin
  52.    if FileExists( FORMFILE )
  53.    then
  54.       writeln( FORMFILE, ' already exists' )
  55.    else begin
  56.       writeln( 'Creating new ', FORMFILE );
  57.       MakeFile( NewForm, FORMFILE );
  58.    end { else }
  59. end. { MakeForm }
  60.